home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / c_news / 16 / sets / setsourc / setprint.c < prev    next >
C/C++ Source or Header  |  1989-03-23  |  1KB  |  51 lines

  1. #include <stdio.h>
  2. #include <stdarg.h>
  3. #include "sets.h"
  4. /*************************************************************************
  5.      REV. 3-19-89: Added c<aset->set_size as upper limit in set_print.
  6.                    This allows set_size smaller than 256. 
  7.  
  8. **************************************************************************
  9. *************************************************************************/
  10.                      void set_print(set *aset)
  11. /*************************************************************************/
  12. /* Prints current members of the set. */
  13. {
  14. char c;
  15. int i;
  16. boolean b;
  17.  
  18. printf("[");
  19. switch(aset->base_type) {
  20.     case BOOLEAN:
  21.                 for(b=FALSE; b<=TRUE; b++)
  22.                     if(in_set(aset,b) == TRUE) {
  23.                         if(b == TRUE)
  24.                             printf("TRUE ");
  25.                         else
  26.                             printf("FALSE ");
  27.                         }
  28.                 break;
  29.  
  30.     case CHARACTER:  /* prints all but \0xff */
  31.  
  32.                /* REV. 3-19-89: added c<aset->set_size as upper limit. */
  33.                /* This allows set_size smaller than 256.               */
  34.  
  35.                 for(c='\x00';(c<'\xff')&&(c<aset->set_size);c++) {
  36.                     if(in_set(aset,(c & 0xff)) == TRUE)
  37.                            printf("%c",c);
  38.                 }
  39.                 break;
  40.     case UNIVERSAL:
  41.     case ENUMERATED:
  42.     case SUBRANGE:
  43.                 for(i=0; i<aset->set_size; i++)
  44.                     if(in_set(aset,i) == TRUE)
  45.                         printf("%d ",i);
  46.     }
  47. printf("]");
  48.  
  49. }  /* end set_print */
  50.  
  51.